package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.SpecDao;
import com.itheima.entity.PageResult;
import com.itheima.pojo.Spec;
import com.itheima.service.SpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.Parameter;

/**
 * @author Gu-1996
 */
@Service(interfaceClass = SpecService.class)
@Transactional
public class SpecServiceImpl implements SpecService{
    @Autowired
    private SpecDao specDao;


    @Override
    public PageResult findPage(Integer page, Integer size, String name, String options, Integer templateId) {
        PageHelper.startPage(page,size);
        Page<Spec> page1 = specDao.selectByCondition(name, options, templateId);
        return new PageResult(page1.getTotal(), page1.getResult());

    }

    //新增
    @Override
    public void add(Spec spec) {
        specDao.add(spec);
    }

    //根据id查查询数据
    @Override
    public Spec findById(Integer id){
        return specDao.findById(id);
    }

    @Override
    public void update(Spec spec) {
        specDao.update(spec);
    }

    @Override
    public void delete(Integer id) {
        specDao.delete(id);
    }
}
